package L1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class _085 {
    /**
     * 试试手气
     */
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] line = reader.readLine().split(" ");
        int N = Integer.valueOf(reader.readLine());
        for (int i = 0; i < 6; i++) {
            int[] arr = new int[7];
            int temp = Integer.valueOf(line[i]);
            arr[temp] = 1;
            for (int j = 0; j < N; j++) {
                for (int l = 6; l > 0; l--) {
                    if (arr[l] == 0) {
                        arr[l] = 1;
                        temp = l;
                        break;
                    }
                }
            }
            if (i==5){
                System.out.println(temp);
            }else
                System.out.print(temp + " ");
        }
    }
}
